#include <stdio.h>

int calc(char a[])
{
    int i, result;

    for (result = a[1], i = 2; a[i] != '*'; i++)

    {
        result ^= a[i];
    }
    return result;
}
void main()

{
    char a[] = "$GNGGA,030409.00,2308.09149,N,11320.35677,E,2,11,1.08,32.9,M,-5.4,M,1.0,3357*4b";
    char a1[] = "$GNRMC,030410.00,A,2308.09165,N,11320.35698,E,0.048,,080821,,,F,V*18";

    printf("result a=%x\n", calc(a));
    printf("result a1=%x\n", calc(a1));
}
